package cn.fancylab.template.untrans.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.fancylab.support.ResultCode;
import cn.fancylab.support.ResultCodeHelper;
import cn.fancylab.template.untrans.OpenFireService;
import cn.fancylab.xmpp.magent.MessageListener;
import cn.fancylab.xmpp.magent.WebContainerMonitorAgent;

@Service("openFireService")
public class OpenFireServiceImpl implements OpenFireService {

	@Autowired
	private WebContainerMonitorAgent webContainerMonitorAgent;

	public ResultCode sendMessage(String username, String content, String uniqSubject, MessageListener call) {
		if (StringUtils.isBlank(username)) {
			return ResultCodeHelper.CODE11_PARAMS_REQUIRED("用户名不能为空！");
		}
		System.out.println("openfire sendmsg : " + content);
		webContainerMonitorAgent.getClient().sendMsg(username, content, uniqSubject, call);

		return ResultCode.getSuccess("已发送");
	}
}